/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036.kiss.Entity;

import java.util.Objects;

/**
 *
 * @author Vasa
 */
public class StudentDTO {
    
    private Long id;
    private String jmeno;
    private String prijmeni;
    private String username;
    private String heslo;
    private int pohlavi;
    private Double stavKonta;

    public Long getId() {
        return id;
    }

  public StudentDTO setId ( final Long id ) {

    if ( id != null ) {

      this.id = new Long ( id.longValue () );
    }

    return this;
  }

    public String getJmeno() {
        return jmeno;
    }

    public void setJmeno(String jmeno) {
        this.jmeno = jmeno;
    }

    public String getPrijmeni() {
        return prijmeni;
    }

    public void setPrijmeni(String prijmeni) {
        this.prijmeni = prijmeni;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getHeslo() {
        return heslo;
    }

    public void setHeslo(String heslo) {
        this.heslo = heslo;
    }

    public int getPohlavi() {
        return pohlavi;
    }

    public void setPohlavi(int pohlavi) {
        this.pohlavi = pohlavi;
    }

    public Double getStavKonta() {
        return stavKonta;
    }

    public void setStavKonta(Double stavKonta) {
        this.stavKonta = stavKonta;
    }

    @Override
    public String toString() {
        return "Student{" + "id=" + id + ", jmeno=" + jmeno + ", prijmeni=" + prijmeni + ", username=" + username + ", heslo=" + heslo + ", pohlavi=" + pohlavi + ", stavKonta=" + stavKonta + '}';
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 79 * hash + Objects.hashCode(this.id);
        hash = 79 * hash + Objects.hashCode(this.jmeno);
        hash = 79 * hash + Objects.hashCode(this.prijmeni);
        hash = 79 * hash + Objects.hashCode(this.username);
        hash = 79 * hash + Objects.hashCode(this.heslo);
        hash = 79 * hash + this.pohlavi;
        hash = 79 * hash + Objects.hashCode(this.stavKonta);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final StudentDTO other = (StudentDTO) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        if (!Objects.equals(this.jmeno, other.jmeno)) {
            return false;
        }
        if (!Objects.equals(this.prijmeni, other.prijmeni)) {
            return false;
        }
        if (!Objects.equals(this.username, other.username)) {
            return false;
        }
        if (!Objects.equals(this.heslo, other.heslo)) {
            return false;
        }
        if (this.pohlavi != other.pohlavi) {
            return false;
        }
        if (!Objects.equals(this.stavKonta, other.stavKonta)) {
            return false;
        }
        return true;
    }
    
    @Override
    public Object clone () {
        try {

            return ( (StudentDTO) super.clone () ).setId ( this.id );
        } catch ( CloneNotSupportedException ex ) {

        assert false: "CloneNotSupportedException thrown";
        return null;
        }
    }
    
    public void checkState () {
        final boolean noJmeno = this.jmeno == null || this.jmeno.isEmpty ();
        final boolean noPrijmeni = this.prijmeni == null || this.prijmeni.isEmpty ();
        final boolean noUsername = this.username == null || this.username.isEmpty ();
        final boolean noHeslo = this.heslo == null || this.heslo.isEmpty ();
        final boolean noPohlavi = this.pohlavi > 1 || this.pohlavi < 0;
        final boolean noStavKonta = this.stavKonta == null;

        if ( noJmeno && noPrijmeni && noUsername && noHeslo && noPohlavi && noStavKonta )  {

            throw new IllegalStateException ( "Jmeno, prijmeni, username, heslo, pohlavi a stav konta musi byt nastaveny" );
        }
    }
}
